package com.zkw.group.service;

import com.zkw.group.entity.User;
import com.zkw.group.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserService {
    @Autowired
    private UserMapper userMapper;

    //获取用户角色
    public String getRole(String username,String password){
        String pid = userMapper.getRole(username,password);
        return pid;
    }

    //分页获取用户列表
    public List<User> selectAll(String username, int pageStart, int pageSize) {
        return userMapper.selectAll(username,pageStart,pageSize);
    }

    //获取用户条目数
    public int getUserCounts(String username){
        return userMapper.getUserCounts(username);
    }

    //添加用户
    public int addUser(User user) {
        int save = userMapper.addUser(user);
        return save;
    }

    //获取要更新的用户信息以及更新用户
    public User getUpdateUser(String username) {
        return userMapper.getUpdateUser(username);
    }

    public int updateUser(User user) {
        return userMapper.updateUser(user);
    }

    //根据用户名删除用户
    public int deleteUser(String username) {
        return userMapper.deleteUser(username);
    }

}
